import pymongo
import pandas as pd
import time
client = pymongo.MongoClient(host='localhost', port=27017)
db = client.Hypertension
collection = db.TestCnkiPaper

data = pd.read_csv('/Users/xiexiaohao/Desktop/paperInfo.csv')
print(data['title'])



for i in range(len(data['title'])):
    obj = {}
    obj['title'] = data['title'][i]
    obj['author'] = data['authors'][i]
    obj['author_info'] = ''
    obj['count'] = 0
    obj['date'] = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
    obj['is_marked'] = False
    obj['is_submit'] = False
    obj['is_update'] = False
    obj['journal'] = data['source'][i]
    obj['keywords'] = data['keyWords'][i]
    obj['src'] = '维普资讯'
    obj['summary'] = data['abstract'][i]
    obj['url'] = ''
    obj['valid'] = True
    obj['year'] = ''

    collection.insert(obj)

